API Documentation
Public Member Functions | List of all members
nkGraphics::Program Class Referenceabstract

Holds all informations related to GPU programs, and manages their compilation. More...

Inheritance diagram for nkGraphics::Program:
nkGraphics::Resource nkExport::Exportable

Public Member Functions

 Program ()
 
virtual ~Program ()
 
const ProgramCompilationResultgetLastCompilationResult () const
 
bool isFromFile () const
 
bool isFromMemory () const
 
ProgramSourcesHoldergetMemory () const
 
const InfiniteByteMaskgetSemantics () const
 
unsigned int getId () const
 
PROGRAM_TYPE getType () const
 
PROGRAM_COMPILATION_PROFILE getProfile () const
 
virtual void setFromMemory (const ProgramSourcesHolder &memory)
 
virtual void setDefines (const ProgramSourcesHolder &memory)
 
void setFromFiles (const char *folder)
 
void setId (unsigned int id)
 
void setProfile (PROGRAM_COMPILATION_PROFILE profile)
 
bool prepareMemoryWithFiles ()
 
virtual bool loadFromMemory ()=0
 
virtual bool tryToLoadFrom (ProgramSourcesHolder &newMemory)=0
 
virtual bool load () override
 
virtual void unload () override
 
virtual void exportClassToTree (nkExport::Node *rootNode) override
 
virtual void importClassFromTree (nkExport::Node *rootNode) override
 
- Public Member Functions inherited from nkGraphics::Resource
 Resource ()
 
 Resource (const char *path)
 
virtual ~Resource ()
 
bool isReadyForRendering () const
 
bool isUnloaded () const
 
RESOURCE_LOAD_STATE getLoadState () const
 
std::string_view getResourcePath () const
 
RESOURCE_TYPE getResourceTypeName () const
 
std::string_view getResourceName () const
 
bool getHidden () const
 
virtual void setResourcePath (const std::string_view &path)
 
void setResourceName (const std::string_view &name)
 
void setHidden (bool value)
 
- Public Member Functions inherited from nkExport::Exportable
 Exportable ()
 
virtual ~Exportable ()
 

Detailed Description

Holds all informations related to GPU programs, and manages their compilation.

Constructor & Destructor Documentation

◆ Program()

nkGraphics::Program::Program ( )

Constructor. See ShaderManager::createOrRetrieveProgram().

◆ ~Program()

virtual nkGraphics::Program::~Program ( )
virtual

Destructor.

Member Function Documentation

◆ getLastCompilationResult()

const ProgramCompilationResult& nkGraphics::Program::getLastCompilationResult ( ) const
Returns
The last compilation result. Generated whenever a loading is called.

◆ isFromFile()

bool nkGraphics::Program::isFromFile ( ) const
Returns
Whether the program has been made from files (true) or not (false).

◆ isFromMemory()

bool nkGraphics::Program::isFromMemory ( ) const
Returns
Whether the program has been made from an internal memory (true) or not (false).

◆ getMemory()

ProgramSourcesHolder* nkGraphics::Program::getMemory ( ) const
Returns
The currently used sources memory.

◆ getSemantics()

const InfiniteByteMask& nkGraphics::Program::getSemantics ( ) const
Returns
The semantics of the program.

◆ getId()

unsigned int nkGraphics::Program::getId ( ) const
Returns
The id of the program.

◆ getType()

PROGRAM_TYPE nkGraphics::Program::getType ( ) const
Returns
The type of program. Detected, depending on what kind of memory is loaded.

◆ getProfile()

PROGRAM_COMPILATION_PROFILE nkGraphics::Program::getProfile ( ) const
Returns
The profile use by the program.

◆ setFromMemory()

virtual void nkGraphics::Program::setFromMemory ( const ProgramSourcesHolder memory)
virtual

Sets the program from an already loaded memory set.

The memory used will need to fit some constraints for a Program to find back relevant data :

  • The function to execute in a program needs to be named "main", for all stages except raytracing.
  • For rayctracing stage, depending on their role, entry functions should be named : "miss", "raygen", "closesHit".
Parameters
memoryThe memory to use.

◆ setDefines()

virtual void nkGraphics::Program::setDefines ( const ProgramSourcesHolder memory)
virtual

Sets the defines to use within the program. Can be useful to add defines and then load a program from a folder.

Parameters
memoryThe memory to copy de defines from.

◆ setFromFiles()

void nkGraphics::Program::setFromFiles ( const char *  folder)

Sets the folder from which the program should load its sources. The files that can be loaded are :

  • vertexShader.hlsl -> vertex stage
  • hullShader.hlsl -> hull stage
  • domainShader.hlsl -> domain stage
  • geometryShader.hlsl -> geometry stage
  • pixelShader.hlsl -> pixel stage
  • computeShader.hlsl -> compute stage
  • raytracingShader.hlsl -> raytracing stage
Parameters
folderThe path of the folder to load from, relative to the working directory. See nkResources::ResourceManager for the path naming conventions.

◆ setId()

void nkGraphics::Program::setId ( unsigned int  id)

Sets the id of the program.

Parameters
idThe id to use.

◆ setProfile()

void nkGraphics::Program::setProfile ( PROGRAM_COMPILATION_PROFILE  profile)

Sets the profile to use for compilation.

Parameters
profileThe profile to use.

◆ prepareMemoryWithFiles()

bool nkGraphics::Program::prepareMemoryWithFiles ( )

If the program is defined from a folder, prepares the memory with the source files content.

Returns
If the loading went well (true) or not (false).

◆ loadFromMemory()

virtual bool nkGraphics::Program::loadFromMemory ( )
pure virtual

Loads the program, from the memory currently set.

Returns
If the loading went well (true) or not (false).

◆ tryToLoadFrom()

virtual bool nkGraphics::Program::tryToLoadFrom ( ProgramSourcesHolder newMemory)
pure virtual

Tries to load from a provided memory, and swap the current state with the newly submitted state only on success. If it fails, the program state is not changed.

Parameters
newMemoryThe memory to try to load from.
Returns
If the loading went well (true) or not (false).

◆ load()

virtual bool nkGraphics::Program::load ( )
overridevirtual

Loads and compiles the program.

Returns
If the loading went well (true) or not (false).

Implements nkGraphics::Resource.

◆ unload()

virtual void nkGraphics::Program::unload ( )
overridevirtual

Unloads and frees the internal resources of the program.

Implements nkGraphics::Resource.

◆ exportClassToTree()

virtual void nkGraphics::Program::exportClassToTree ( nkExport::Node rootNode)
overridevirtual

Basic exporting capabilities.

Parameters
rootNodeThe tree to export to.

Implements nkExport::Exportable.

◆ importClassFromTree()

virtual void nkGraphics::Program::importClassFromTree ( nkExport::Node rootNode)
overridevirtual

Basic importing capabilities.

Parameters
rootNodeThe tree to import from.

Implements nkExport::Exportable.


The documentation for this class was generated from the following file: